# hemi of a triangle strip in 3D space, centered at (0,0,0)
# element 0 starts at (1,0,0)

#!/usr/bin/env python

from scipy import *
from enthought.mayavi import mlab
import sys
sys.path.append( '../' )

from field import template_fields
from field import geometric_field

# hemi parameters
radius = 10.0
elements = 5

eval_density = 20

# make hemi and parameters
#~ (hemi, xparam, yparam, zparam) = template_fields.tri_hemisphere( radius, elements )
(hemi, xparam, yparam, zparam) = template_fields.four_tri_patch_hemisphere( radius, elements )

# evaluate
x = hemi.evaluate_field_in_mesh( eval_density, xparam )
x = array(x).flatten()

y = hemi.evaluate_field_in_mesh( eval_density, yparam )
y = array(y).flatten()

z = hemi.evaluate_field_in_mesh( eval_density, zparam )
z = array(z).flatten()


#~ plot.figure()
#~ plot.hold(True)
#~ 
#~ # plot field over mesh
#~ plot.scatter(x,y)
#~ 
#~ # plot ensemble nodes
#~ plot.scatter( array(xparam).flatten(), array(yparam).flatten(), marker = 's', s = 100, c='r' )
#~ 
#~ plot.show()

#~ a = mlab.orientationaxes()
p = mlab.points3d( x,y,z, mode = 'sphere', scale_factor = 0.5)
n = mlab.points3d( xparam, yparam, zparam, mode = 'sphere', scale_factor = 1.0, color = (1,0,0) )
mlab.show()
